package com.guli.file.controller;

import com.guli.common.response.Result;
import com.guli.file.config.FastDfSClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("file/upload")
public class FastDFSUploadController {
    @Autowired
    private FastDfSClient fastDfSClient;

    @PostMapping("/fastdfs")
    public Result fastDfSUpload(@RequestParam("file")MultipartFile file){
        String url= fastDfSClient.uploadThumbImage(file);
        if(url!=null){
            return new Result(true, "100",url);
        }
        return  new Result(false, "000", "上传失败");
    }
}
